package com.sw.haruka.helper.utils

import android.annotation.SuppressLint
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import androidx.appcompat.app.AppCompatActivity
import com.sw.haruka.view.MainActivity
import java.lang.ref.WeakReference

object ActivityUtils {

    var mainActivity: WeakReference<MainActivity>? = null
    private set

    fun bindMainActivity(mainActivity: MainActivity) {
        this.mainActivity = WeakReference(mainActivity)
    }

    fun portrait(activity: AppCompatActivity) {
        if (activity.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
            activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
        }
    }

    fun landscape(activity: AppCompatActivity) {
        if (activity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
        }
    }

}